#博客首页自动化测试脚本
#同理为了解耦等，这里将其封装成类
from selenium.webdriver.common.by import By
from common.tool import BlogDriver

class BlogList:
    url = ""
    driver = ""
    def __init__(self):
        self.driver = BlogDriver.driver
        self.url = "http://8.137.19.140:9090/blog_list.html"
        self.driver.get(self.url)
    #同理根据测试用例编写脚本
    #测试登录情况下的博客首页
    def BlogListInLogin(self):
        #同理，按照预期结果来测试即可
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("zhangsan")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123456")
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()

        #标题是否存在（前提登录成功并且元素出现）
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(2) > div.title")
        #内容是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(2) > div.desc")
        #查看按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a")
        #当然还有个人信息相关元素都需要一一测试是否存在，这里省略

        BlogDriver.saveScreenShot()

    #测试未登录情况下的博客首页
    #def BlogListIn(self):




